package br.com.fsa.aplication.Util;

import java.util.Date;

import org.hibernate.HibernateException;

import br.com.fsa.aplication.Database.LogDAO;
import br.com.fsa.aplication.Exception.ConectionException;
import br.com.fsa.aplication.Model.bean.Log;
import br.com.fsa.aplication.Model.bean.TipoEntidade;
import br.com.fsa.aplication.Model.bean.TipoLog;

public class GravaLog
{

	public static void Gravar(String _Descricao, long _UsuarioID,
			long _DocumentoID, TipoEntidade _Tipo, long _TempoProcessamento, TipoLog _TipoLog )
	{
		try
		{
			Log pLog = new Log();
			pLog.setClienteID(_UsuarioID);
			pLog.setData(new Date());
			pLog.setDescricao(_Descricao);
			pLog.setDocumentoID(_DocumentoID);
			pLog.setTipoEntidade(_Tipo);
			pLog.setTempoProcessamento(_TempoProcessamento);
			pLog.setTipoLog(_TipoLog);
			LogDAO dao = new LogDAO();
			dao.save(pLog);
		}
		catch (HibernateException e)
		{
			Util.gravaLog(e.getMessage());
		}
		catch (ConectionException e)
		{
			Util.gravaLog(e.getMessage());
		}

	}
}
